package com.rest.demo.functional.time;

import java.time.LocalDateTime;
import java.time.Month;
import java.time.Period;
import java.time.format.DateTimeFormatter;

/**
 * @author Administrator
 * @decription
 * @Date 2018-01-29 14:44
 */
public class LocalDateTimeDemo {

    public static void main(String[] args) {
        LocalDateTime localDateTime = LocalDateTime.now();
        System.out.println(localDateTime);

        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        System.out.println(localDateTime.format(dateTimeFormatter));

        LocalDateTime localDateTime1 = LocalDateTime.of(2018, Month.JULY,23,15,15,12);
        System.out.println(localDateTime1);
        System.out.println("当前月:"+localDateTime.getMonth());

        System.out.println(localDateTime.plus(Period.ofWeeks(1)).format(dateTimeFormatter));
    }
}
